Code cleanup and final adjustments
